package com.weixin.paleituo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.weixin.paleituo.R;
import com.weixin.paleituo.base.BaseRecycleAdapter;
import com.weixin.paleituo.bean.OrderGoods;
import com.weixin.paleituo.help.RecycleViewHolder;
import com.weixin.paleituo.util.UIUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 商品阅览大图
 *
 * @author fengzhen
 * @version v1.0, 2018/4/1
 */
public class GoodsPreviewRecycleAdapter extends BaseRecycleAdapter<OrderGoods> {

    public GoodsPreviewRecycleAdapter(Context context, List<OrderGoods> datas) {
        super(context, datas, R.layout.item_goods_preview_pic);
    }

    @Override
    protected void setData(RecycleViewHolder holder, OrderGoods goods, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        Glide.with(mContext)
                .load(mDatas.get(position).getListUrl())
                .into(viewHolder.mImgGoodsItemPreview);
    }

    @Override
    public RecycleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(UIUtils.inflate(mContext, R.layout.item_goods_preview_pic, parent, false));
    }

    static class ViewHolder extends RecycleViewHolder {
        @BindView(R.id.img_goods_item_preview)
        ImageView mImgGoodsItemPreview;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
